package com.fy56.platform.goodsTracking.web;

import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;

public class CommonLocalLinkedQueue {
	private static ConcurrentLinkedQueue<Map<String, Object>> queue;
	private static int count = 1; // 线程个数
	// CountDownLatch，一个同步辅助类，在完成一组正在其他线程中执行的操作之前，它允许一个或多个线程一直等待。
	public static CountDownLatch latch;

	public static ConcurrentLinkedQueue<Map<String, Object>> getQueue() {
		if (queue == null) {
			queue = new ConcurrentLinkedQueue<Map<String, Object>>();
		}
		return queue;
	}

	public static CountDownLatch getLatch() {
		if (latch == null) {
			latch = new CountDownLatch(count);
		}
		return latch;
	}

	/**
	 * 生产
	 */
	public static void offer(Map<String, Object> data) {
		CommonLocalLinkedQueue.getQueue().offer(data);
	}
}